package br.com.gerador.main;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;

import br.com.gerador.icomponent.IGComponent;
import br.com.gerador.icomponent.IGProprierdade;

public class PnlPropriedades extends JPanel{
	IGProprierdade component;
	AbstractTableModel model;
	JTable table;

	public PnlPropriedades() {
		super(new FlowLayout(FlowLayout.LEFT));
		setPreferredSize(new Dimension(200,Short.MAX_VALUE));
		setBackground(Color.LIGHT_GRAY);
		setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK));
		setTable();
	}
	
	public void setComponent(IGProprierdade comp){
		component = comp;
	}
	
	private void setTable(){
		table = new JTable(model);
		//table.setTableHeader();
		table.setPreferredSize(new Dimension(190, Short.MAX_VALUE));
		add(table);
	}
	
	public void bind(){
		String[][] data = component.getPropriedades();
		model = new PropriedadeData(data,component);
		table.setModel(model);
	}
}
